package ru.study.thinkin.chapter9;

import java.util.Arrays;

class Processor {
	
	public String name() {
		return getClass().getSimpleName();
	}
	
	Object process(Object input) {
		return input;
	}
}

class Upcase extends Processor {
	
	@Override
	String process(Object input) {
		return ((String)input).toUpperCase() ;
	}	
}

class Splitter extends Processor{

	@Override
	String process(Object input) {
		return Arrays.toString(((String)input).split(" "));
	}	
		
} 

public class Apply {
	public static String s = "Disagreemrnt with beliefs";
	
	public static void process(Processor p,Object s) {
		System.out.println("Используем Processor "+p.name());
		System.out.println(p.process(s));
	}
	
	public static void main(String[] args) {
		process(new Upcase(),s);		
		process(new Splitter(),s);
	}

}
